<%@page isELIgnored="false" import="java.net.*" %>
<%@taglib prefix="tiles" uri="struts-tiles" %>
<%@taglib prefix="html" uri="struts-html" %>
<%@taglib prefix="c" uri="jstl" %>
<%@taglib prefix="fn" uri="jstl-fn" %>
					
<%@page import="com.mastercard.assets.web.util.to.UserLogin"%><div id="bodyContent">

						<h1>Usuarios</h1>
                                                
						<table width="100%">
							<tr>
								<td width="30%">
									<h2>
										Usuarios
									</h2>
								</td>
								<td width="70%" align='right'>
									<a href='CrearUsuario.do'>
										<img alt="Crear nuevo usuario" src="images/btnAdd.gif">
									</a>
								</td>
							</tr>
						</table>
						
						<div align='center' style='text-align: center; color: red; font-size: 12px;'>
							${UserLogin.messageError}
						</div>
<c:choose>
	<c:when test="${not empty ActiveUsers}">
						<table class="tabDatos">
							<thead>
								<tr>
									<th>Login</th>
									<th>Nombre</th>
									<th>Email</th>
									<th>Roles</th>
									<th>Bancos</th>
									<th width='80px'>Operaci&oacute;n</th>
								</tr>
							</thead>
<c:forEach items="${ActiveUsers}" var="user">

							<tr>
								<td>${user.login}</td>
								<td>${user.nombre}</td>
								<td><a href="mailto:${user.email}">${user.email}</a></td>
								<td align='center'>
									<table border='0' cellpadding='5'>
										<tr>
										
<c:set value="${user.tblRoles}" var="UserRoles" />
<c:set value="${fn:length(UserRoles)}" var="UserRolesLength" />
<c:set value="${fn:length(UserRoles) - 1}" var="UserRolesLengthBeforeLastIndex" />
<c:choose>
<c:when test="${UserRoles eq ''}">No tiene roles</c:when>
<c:otherwise >
<c:forEach items="${UserRoles}" var="role" varStatus="roleIndex">
<c:if test="${role.status eq 1}">
											<td>${role.nombre}</td>
</c:if>
<c:set value="${(roleIndex.index + 1) mod 3}" var="modulo" />
<c:if test="${modulo eq 0}">
										</tr>
										<tr>
</c:if>
</c:forEach>
</c:otherwise>
</c:choose>
										</tr>
									</table>
								</td>
								<td align='center'>
									<table border='0' cellpadding='5'>
										<tr>
										
<c:set value="${user.tblCuentas}" var="UserCounts" />
<c:set value="${fn:length(UserCounts)}" var="UserCountsLength" />
<c:set value="${fn:length(UserCounts) - 1}" var="UserCountsLengthBeforeLastIndex" />
<c:choose>
<c:when test="${UserCounts eq ''}">No tiene roles</c:when>
<c:otherwise >
<c:forEach items="${UserCounts}" var="count" varStatus="countIndex">
<c:if test="${count.status eq 1}">
											<td>${count.nombre}</td>
</c:if>
<c:set value="${(countIndex.index + 1) mod 3}" var="modulo" />
<c:if test="${modulo eq 0}">
										</tr>
										<tr>
</c:if>
</c:forEach>
</c:otherwise>
</c:choose>
										</tr>
									</table>
								</td>
								<td>
									<table border='0' style="border: none ;">
										<tr>
											<td>
<c:choose>
<c:when test="${user.login ne UserLogin.login}">
												<html:form action="BorrarUsuario.do" method="post" >
												<html:hidden property="operation" value="2"/>
												<html:hidden property="catalogoId" value="13"/>
												<html:hidden property="campo1" value="${user.login}"/>
												<html:hidden property="regId" value="${user.cveUsuario}"/>
												<input type='image' onclick="javascript:if (confirm('Esta seguro que desea borrar el Usuario\n${user.nombre}?')){return true ; }else {return false ;} " src='images/btnEliminar.gif' />
												</html:form>
</c:when>
<c:otherwise>
												&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</c:otherwise>
</c:choose>
											</td>
											<td>&nbsp;</td>
											<td>
												<html:form action="EditarUsuario.do" method="post">
												<html:hidden property="regId" value="${user.cveUsuario}"/>
												<html:hidden property="campo1" value="${user.login}"/>
												<html:hidden property="campo2" value="${user.nombre}"/>
												<html:hidden property="operation" value="3"/>
												<html:hidden property="catalogoId" value="13"/>
												<input type='image' src='images/btnEdit.gif' />
												</html:form>
											</td>
										</tr>
									</table>
								</td>
							</tr>
</c:forEach>
						</table>
						
	</c:when>
	<c:otherwise>
						<div style='text-align: center ; width: 100%; color: gray; font-size: 12px; font-weight: bold ;'>No existen registros</div>
	</c:otherwise>
</c:choose>
						
						
						
					</div>
					<div id="footContent"></div>
<% 
UserLogin user = ( UserLogin ) request.getSession( true ).getAttribute( "UserLogin" ) ;

// en caso de que no sea null
if( user != null )
	user.clearMessageError( ) ;
%>
